package com.stadium.web.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fastsite.common.enums.StatusEnum;
import com.stadium.common.StadiumConstant;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.hibernate.usertype.UserType;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

/**
 * 用户对象 user
 * 
 * @author ruoyi
 * @date 2020-03-14
 */
@ApiModel("用户实体类")
@Table(name="user")
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
public class User implements Serializable
{
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    /** 主键 */
    @Column(name = "ID")
    @ApiModelProperty("主键")
    private Long id;

    /** 用户名 */
    @Column(name = "NAME")
    @ApiModelProperty("昵称")
    private String name;

    /** 昵称 */
    @Ignore
    @Column(name = "PASSWORD")
    @ApiModelProperty("密码")
    private String password;
    /** 手机号 */
    @Column(name = "PHONE")
    @ApiModelProperty("手机号")
    private String phone;

    /** 性别 */
    @Column(name = "SEX")
    @ApiModelProperty("性别")
    private Long sex;

    /** 年龄 */
    @Column(name = "AGE")
    @ApiModelProperty("年龄")
    private Long age;

    /** 余额 */
    @Ignore
    @Column(name = "BALANCE")
    @ApiModelProperty("余额")
    private BigDecimal balance=new BigDecimal("99999");

    /** 创建时间 */
    @Ignore
    @OrderBy("desc")
    @CreatedDate
    @JsonFormat(pattern="yyyy-MM-dd  HH:mm")
        @Column(name = "CREATE_TIME")
    @ApiModelProperty("创建时间")
    private Date createTime;

    @Transient
    @ApiModelProperty("用户类型")
    private Boolean userType;

    public Boolean getUserType() {
        return id!=null && id.equals(StadiumConstant.ADMIN_ID);
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setName(String name) 
    {
        this.name = name;
    }

    public String getName() 
    {
        return name;
    }
    public void setPhone(String phone) 
    {
        this.phone = phone;
    }

    public String getPhone() 
    {
        return phone;
    }
    public void setSex(Long sex) 
    {
        this.sex = sex;
    }

    public Long getSex() 
    {
        return sex;
    }
    public void setAge(Long age) 
    {
        this.age = age;
    }

    public Long getAge() 
    {
        return age;
    }
    public void setCreateTime(Date createTime) 
    {
        this.createTime = createTime;
    }

    public Date getCreateTime() 
    {
        return createTime;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("name", getName())
            .append("phone", getPhone())
            .append("sex", getSex())
            .append("age", getAge())
            .append("balance", getBalance())
            .append("createTime", getCreateTime())
            .toString();
    }
}
